<template>
  <div>
    <div class="team-list">
      <div class="caption">{{ $t('邀请达人榜') }}</div>
      <ul class="list">
        <li v-for="(item, index) in list" :key="item.id" class="item">
          <span v-if="index<3" class="num rank" :class="'s' + (index+1)">No.{{ index+1 }}</span>
          <span v-else class="num">No.{{ index+1 }}</span>
          <span class="id">{{ item.username }}</span>
          <span class="val">{{ item.total_invite_rewards }}</span>
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
import { mapActions } from 'vuex'
export default {
  data () {
    return {
      list: ''
    }
  },
  beforeMount () {
    this.getReferralRank()
      .then((data) => {
        this.list = data.data
      })
  },
  methods: {
    ...mapActions({
      getReferralRank: 'user/getReferralRank'
    })
  }
}
</script>
<style scoped>
.team-list {padding: 10px 15px 15px;}
.team-list .caption {
  text-align: center;
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 12px;
}
.team-list .list {
  box-shadow: 0 0 10px rgba(0, 0, 0, .2);
  border-radius: 10px;
  overflow: hidden;
  padding: 0 10px;
}
.team-list .item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 40px;
  border-top: 1px solid #eee;
}
.team-list .item:first-child {
  border-top: none;
}
.team-list .num {
  position: relative;
  width: 40px;
  text-align: center;
  line-height: 20px;
}
.team-list .num.rank {
  color: #fff;
}
.team-list .num.rank:before {
  content: '';
  position: absolute;
  z-index: -1;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 3px;
  transform: skewX(-10deg);
}
.team-list .num.rank.s1:before {
  background-color: rgb(255, 182, 98);
}
.team-list .num.rank.s2:before {
  background-color: rgb(158, 95, 37);
}
.team-list .num.rank.s3:before {
  background-color: rgb(85, 84, 6);
}
.team-list .id {
  flex-grow: 1;
  padding: 0 15px;
}
</style>
